<?php
/**
 * @author GHoogendoorn
 * @version 0.1
 */
define ("DEBUG_ALL",        0xFFFF);
define ("DEBUG_LEVEL",      DEBUG_ALL);

function error_handler($level, $message, $file, $line, $context) {
    //Handle user errors, warnings, and notices ourself
    if($level === E_USER_ERROR || $level === E_USER_WARNING || $level === E_USER_NOTICE) {
        echo '<div class="error"><strong>Error:</strong> '.$message.'</div>';
        return(true); //And prevent the PHP error handler from continuing
    }
    return(false); //Otherwise, use PHP's error handler
}

function debug_var_dump($var, $lvl=DEBUG_ALL){

    if ($lvl & DEBUG_LEVEL){
        echo "<pre>";
        var_dump($var);
        echo "</pre>";
    }
}

function debug_echo($text, $lvl=DEBUG_ALL){
    
    if ( $lvl & DEBUG_LEVEL ){
        echo $text.'<br />';
    }
}
//Use our custom handler
set_error_handler('error_handler');
?>
